<?php

class query_db extends CI_Model
{
    function CATEGORY_SELECT_ALL()
    {
        $this->db->db_debug = FALSE;
        $query=$this->db->query('SELECT CAT.*,(SELECT COUNT(ID) FROM `sub category` WHERE CATEGORY_ID=CAT.ID) AS COUNT_SUB_CAT FROM `category` AS CAT ORDER BY CAT.ORDER_NO');
        return $query->result_array();
    }
    function SUB_CATEGORY_SELECT_ALL()
    {
        $this->db->db_debug = FALSE;
        $query=$this->db->query('SELECT * FROM `sub category` ORDER BY ORDER_NO');
        return $query->result_array();
    } 
    function getKeyWord($like)
    {
        $this->db->db_debug = FALSE;
        $query=$this->db->query("SELECT WORD FROM `keyword` WHERE WORD LIKE '$like%' ORDER BY WORD");
        return $query->result_array();
    }     
}
?>